package com.ipan.weixin.msg.general;

import org.dom4j.Document;
import org.dom4j.Element;

/**
 * 普通消息
 * 
 * @author iPan
 * @version 2013-12-23
 */
abstract public class PlainMsg extends AbstractXmlMsg {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = -1470564062341330781L;
	
	/** 消息id，64位整型 */
	protected String msgId;

	public PlainMsg() {
		super();
	}

	public PlainMsg(String toUserName, String fromUserName, String createTime, String msgType, TransportType transportType) {
		super(toUserName, fromUserName, createTime, msgType, transportType);
	}

	public PlainMsg(TransportType transportType) {
		super(transportType);
	}

	public String getMsgId() {
		return msgId;
	}

	public void setMsgId(String msgId) {
		this.msgId = msgId;
	}
	
	/**
	 * 接收XML消息
	 */
	@Override
	public void fromXml(Document doc) {
		super.fromXml(doc);
		Element root = doc.getRootElement();
		this.msgId = root.elementTextTrim(EL_MSG_ID);
	}
}
